/*
 * Copyright (C) 2010 The Android Open Source Project 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at 
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */

package com.gameoflife;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

/** 
 * Houses the game view and handles calls to the preferences menu. 
 */
public class GridActivity extends Activity {

	/** The actual display of the game employed by this activity. */
    private GridView _gridView;
    
    /** Constructor for GridActivity adds itself to the activities vector. */
    public GridActivity()
	{
		MainActivity.activities.add(this);
	}

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid);
        
        _gridView = (GridView)findViewById(R.id.grid_view); 
        _gridView.setMode(GridView.RUNNING);
    }
    
    /** Open the preferences menu when the menu button is pressed. */
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
    	startActivity(new Intent(this, PreferencesActivity.class));
        return true;
    }
    
    /** Set the game mode to paused. */
    @Override
    protected void onPause() {
        super.onPause();
        _gridView.setMode(GridView.PAUSE);
    }
}